﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:converters="clr-namespace:MaxStoreErp.Core.Converters;assembly=MaxStoreErp.Core"
                    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                    mc:Ignorable="d">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MaxStoreShop.Media;component/Icons.xaml" />
    </ResourceDictionary.MergedDictionaries>
    <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    <DataTemplate x:Key="EditColumnItemTemplate">
        <StackPanel Orientation="Horizontal" Visibility="{Binding RelativeSource={RelativeSource AncestorType=ListViewItem}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
            <Button Margin="0,0,8,0"
                    HorizontalAlignment="Center"
                    BorderThickness="0"
                    Command="{Binding EditSelectedItemCommand}"
                    DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl},
                                          Path=DataContext}"
                    ToolTip="Правка выбранной строки">
                <Path Width="12"
                      Height="12"
                      Data="{StaticResource EditIcon}"
                      Fill="{DynamicResource BlackBrush}"
                      Stretch="Uniform" />
            </Button>
            <Button HorizontalAlignment="Center"
                    BorderThickness="0"
                    Command="{Binding DeleteItemCommand}"
                    DataContext="{Binding RelativeSource={RelativeSource AncestorType=UserControl},
                                          Path=DataContext}"
                    ToolTip="Удаление выбранной строки">
                <Path Width="12"
                      Height="12"
                      Data="{StaticResource DeleteIcon}"
                      Fill="{DynamicResource BlackBrush}"
                      Stretch="Uniform" />
            </Button>
        </StackPanel>
    </DataTemplate>

    <Style TargetType="ListViewItem">
        <Style.Triggers>
            <Trigger Property="IsKeyboardFocusWithin" Value="true">
                <Setter Property="IsSelected" Value="true" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style TargetType="{x:Type UserControl}" x:Key="EditorStyle">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <ContentPresenter Content="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=Content}" />
                        <WrapPanel Grid.Row="1"
                                   Grid.Column="0"
                                   HorizontalAlignment="Center"
                                   Orientation="Horizontal">
                            <Button Width="44"
                                    Height="44"
                                    Margin="6"
                                    BorderThickness="0"
                                    Command="{Binding CancelCommand}"
                                    IsCancel="True"
                                    Style="{DynamicResource MetroCircleButtonStyle}"
                                    TabIndex="10"
                                    ToolTip="Отменить сохранение">
                                <Path Width="32"
                                      Height="32"
                                      Data="{StaticResource CancelIcon}"
                                      Fill="{DynamicResource BlackBrush}"
                                      Stretch="Uniform" />
                            </Button>

                            <Button Width="44"
                                    Height="44"
                                    Margin="6"
                                    BorderThickness="0"
                                    Command="{Binding SaveCommand}"
                                    IsDefault="True"
                                    Style="{DynamicResource MetroCircleButtonStyle}"
                                    TabIndex="9"
                                    ToolTip="Сохранить изменения">
                                <Path Width="32"
                                      Height="32"
                                      Data="{StaticResource AcceptIcon}"
                                      Fill="{DynamicResource BlackBrush}"
                                      Stretch="Uniform" />
                            </Button>
                        </WrapPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>